<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title><?=$da['title']?></title>
    <link rel="stylesheet" type="text/css" href="mode/weui/weui.min.css"/>
    <link rel="stylesheet" type="text/css" href="web/res/fontawesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="webmain/css/rui.css">
    <script type="text/javascript" src="js/base64-min.js"></script>

    <script type="text/javascript" src="webmain/we/ying/dist/jquery.min.js"></script>
    <script type="text/javascript" src="webmain/we/ying/ying.js"></script>

    <script type="text/javascript" src="webmain/we/ying/dist/dropload.js"></script>
    <script type="text/javascript" src="webmain/we/ying/dist/dropload.min.js"></script>
    <link rel="stylesheet" href="webmain/we/ying/dist/dropload.css">




    <style>
        body,html{background-color:#f1f1f1;}

        .weui_tab{position:fixed;bottom:0px;width:100%;height:50px}
        .weui_navbar_item{font-size:16px;}
        .weui_navbar_item span{position:absolute;left:3px;top:3px}
        .weui_navbar_item:active{background-color:#f5f5f5}

        .contline{padding-top:10px;color:#999999;font-size:14px;text-align:center;}
        .contlist{margin:15px;padding:8px 10px;position:relative; background:white}
        .contlist:active,.active{ background-color:#f1f1f1}
        .contlist .title{font-size:16px}
        .contlist .dt{font-size:12px;color:#aaaaaa;}
        .contlist .xq{color:#3D8EDB;font-size:14px;padding-top:7px}
        .contlist .xq span{float:right}
        .contlist .cont{font-size:14px;padding:10px 0px}
        .contlist .imgs{height:130px;overflow:hidden;margin:5px 0px}
        .contlist .zt{font-size:10px;position:absolute;top:1px;right:0px;padding:1px 3px;background-color:red;color:white}
        .contlist .face{font-size:14px;padding:5px 0px;height:30px;overflow:hidden;}
        .contlist .face img{border-radius:15px;height:24px;width:24px;margin-right:5px}
        .contlist .opt{font-size:10px;position:absolute;bottom:1px;right:1px;padding:1px 3px;color:#aaaaaa}

        .showblank{color:#aaaaaa;font-size:14px;padding-bottom:15px;text-align:center}
        .showblanks{padding:10px;color:#aaaaaa;font-size:12px;text-align:center}
        .notrecord{text-align:center;font-size:20px;padding-top:50px;color:#aaaaaa}

        body,html{
            height: 100%;
        }

        ul li{width:90%; margin-left: 5%; margin-bottom: 20px; border-radius:5px; display: flex;flex-direction:column; background-color: white}

        .div1{justify-content: space-between; display:flex; border-radius: 5px 5px 0px 0px; background-color: rgb(27,205,138)}

        .div2{display: flex;flex-direction:row; border: 1px rgb(223,223,223) solid; border-bottom: 1px; border-left: 0px;border-right: 0px; padding:3px 10px;justify-content: space-between;}

    </style>
    <script>

        var json = <?=json_encode($dailyArr)?>;

        var json1 = <?=json_encode($commentArr)?>;

        var json2 = <?=json_encode($xxdataArr)?>;

        var json3 = <?=json_encode($lowidArr)?>;

        var json4 = <?=json_encode($lowdailyArr)?>;



        var d = new Date;

        var day=d.getDate()

        var month=d.getMonth() + 1

        var year=d.getFullYear()

        var timecurrent = year + "-" + month + "-" + day;

        var sincetime = "2017-08-01";

        var tmp = timecurrent.split("-");

        var T1 = new Date(tmp[0],tmp[1]-1,tmp[2]);

        tmp = sincetime.split("-");

        var T2 = new Date(tmp[0],tmp[1]-1,tmp[2]);

        var sincedays = days(T1,T2);

        function days(t1,t2) {

            return (t1.getTime() - t2.getTime())/60/60/24/1000
        }   //获取天数


        var dropload;


        var page =0;


        var  ulhtml ='';

        var dailyTime = []; //写日报的日期数组

        var xxarr =[];


        for (var i = 0; i< json2.length;i++ ){

            var obj = json2[i];
            xxarr.push(obj.dt)
        }





        function load(){



            var isPageHide = false;
            window.addEventListener('pageshow', function () {
                if (isPageHide) {
                    window.location.reload();
                }
            });
            window.addEventListener('pagehide', function () {
                isPageHide = true;
            });


            dropload = $('.element').dropload({

                scrollArea : window,

                loadDownFn : function(me){

                    $.ajax({

                        type: 'POST',
                         url: "http://oa.wxlion.com/index.php?d=we&m=ying&a=daily&num=daily",
                       // url: "http://localhost/oa/public_html/index.php?d=we&m=ying&a=daily&num=daily",

                        data: {

                            check:2,
                            page:++page
                        },
                        datatype: "json",
                        success: function(result) {

                            var arr = eval(result);

                            json = arr;

                            mydaily();

                            me.resetload();    // 每次数据加载完，必须重置

                            if(!json.length && page*10 >sincedays){

                                dropload.lock('down');
                                me.noData();
                                me.resetload();

                            }

                        },
                        //调用出错执行的函数
                        error: function(error1) {


                        }
                    });


                }

            });
        }



        //我的日报
        function mydaily(){


            var dailyTime = []; //写日报的日期数组


            for (var i = 0;i<json.length; i++){

                var obj = json[i];
                var str = obj.dt;
                dailyTime.push(str);
            }


            for (var i = 10*page-10; i < 10*page; i++) {

                if(i > sincedays){break;}

                var d = new Date;

                d.setDate(d.getDate() - i);

                var day=d.getDate()

                var month=d.getMonth() + 1

                var year=d.getFullYear()

                if (month >= 1 && month <= 9) {
                    month = "0" + month;
                }

                if (day >= 1 && day <= 9) {
                    day = "0" + day;
                }

                var time = year + "-" + month + "-" + day;


                if (!array_contain(xxarr,time)) {


                    if (array_contain(dailyTime, time)) {


                        for (var m = 0; m < dailyTime.length; m++) {

                            var s1 = json[m];


                            if (dailyTime[m] == time) {

                                ulhtml += ' <li onclick="detail('+s1.id +',0)" > <div class="div1"><span style="margin:5px 10px ">' + s1.dt + '</span><span style="margin:3px 10px ">日报</span></div> <span style="margin: 10px">' + s1.content + '</span> <div class="div2"> <span>提交时间:&nbsp&nbsp' + s1.optdt.substr(0,10) + '</span> <span style="float: right;display: inline-block;" >'+ commentnum(s1.id)+'评论</span> </div> </li>';

                            }

                        }

                    }
                    else {

                        ulhtml += ' <li style=" width:90%; margin-left: 5%; margin-bottom: 20px; padding: 8px 0px; border-radius: 5px;display: flex;flex-direction:column; background-color: white"><div style="display: flex;flex-direction:row;justify-content: space-between; "><span style="margin:5px 10px">' + time + ' </span><span style="margin:5px 10px">未提交日报<span</div>  </li>';
                    }

                }

            }
            $("#kqul").html(ulhtml);
        }




        function detail(Mid,type){


            var url='index.php?a=detail&m=ying&d=we&num=daily&show=we&mid='+ Mid +'&type='+ type +'';

            location.href=url;


            //添加日报查看记录
            $.ajax({

                type: 'POST',
                url: "http://oa.wxlion.com/index.php?d=we&m=ying&a=daily&num=daily",

                //url: "http://localhost/oa/public_html/?d=we&m=ying&a=daily&num=daily",

                data: {

                    check:1,
                    mid:Mid,
                },
                datatype: "json",
                success: function(result) {


                },
                //调用出错执行的函数
                error: function(error1) {


                }
            });

        }

        function writedaily(){


            var url='index.php?a=write&m=ying&d=we&num=daily&show=we';

            location.href=url;

        }



        function golow(){


            var url='index.php?a=lowdaily&m=ying&d=we&num=daily&show=we';

            location.href=url;
        }



        window.onload=function(){

            load();


            if(!json3.length){


                $("#low").hide();
            }
            $("#kqul").html(ulhtml);
        }

        function contain(s,time) {

            var jArr = [];

            for (var i=0; i<json4.length;i++){

                var obj = json4[i];
                if(obj.dt == time && obj.uid == s.id){

                    jArr.push(obj);

                }
            }

            if(jArr.length){

                return jArr;
            }

            return false;

        }

        function commentnum(id) {

            var num = 0;

            for (var i = 0; i < json1.length;i++){

                var j = json1[i]

                if (j.mid == id){
                     num ++;
                }

            }
            return num;
        }



        function array_contain(array, obj){
            for (var i = 0; i < array.length; i++){
                if (array[i] == obj)//如果要求数据类型也一致，这里可使用恒等号===
                    return true;
            }
            return false;
        }


    </script>
</head>




<body class="main">

    <div class="element" style="width: 100%;  margin-top: 10px; overflow: auto; margin-bottom: 10px">

        <ul id="kqul" >


        </ul>

    </div>
</body>



<div style="height:50px;overflow:hidden"></div>
<div id="footerdiv" style="z-index:5" class="weui_tab">
    <div class="weui_navbar weui_tabbar">
        <div id="low" class="weui_navbar_item" onclick="golow()">下属日报</div>
        <div class="weui_navbar_item" onclick="writedaily()">+写日报</div>
    </div>
</div>



<?php
if($yyurljs!='')echo '<script type="text/javascript" src="'.$yyurljs.'"></script>'."\n";
        ?>

<script type="text/javascript" src="web/res/js/jquery-imgview.js"></script>
<script type="text/javascript" src="web/res/js/jquery-rockupload.js"></script>
<script type="text/javascript" src="web/res/js/jquery-changeuser.js"></script>

</>

</html>